package com.demo.lifecycle;

import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestCycle {
    //spring工厂
    @Test
    public void test2(){
        String xmlPath="com/demo/lifecycle/beans.xml";
        ClassPathXmlApplicationContext classPathXmlApplicationContext=new ClassPathXmlApplicationContext(xmlPath);
        UserService userService = (UserService) classPathXmlApplicationContext.getBean("userService");
        userService.addUser();
        //1.容器必须close，销毁方法执行
        //2.此方法接口未提供，由实现类提供
        //3.必须是单例的
        classPathXmlApplicationContext.close();
    }
}
